package com.proracing.app.eitinerer.db;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import java.io.IOException;
import java.net.URISyntaxException;

/**
 *
 * @author mateusz
 */
public class mc_DBHandler {
    
    private void mc_DBHandler() {
        
    }
    
    public String connect(String iv_login, String iv_pass) throws URISyntaxException, IOException {
        String lv_Link = "http://proracing.org.pl/mateusz/con_db.php?loginname="
        +iv_login+"&password="+iv_pass;
        //URL lr_Url = new URL(lv_Link);
        HttpClient lr_Client = new DefaultHttpClient();
        HttpGet lr_Request = new HttpGet();
        lr_Request.setURI(new URI(lv_Link));
        HttpResponse lr_Response = lr_Client.execute(lr_Request);
        BufferedReader lr_Input = new BufferedReader(new InputStreamReader(lr_Response.getEntity().getContent()));
        StringBuffer lv_Input = new StringBuffer("");
        String lv_Line="";
        while ((lv_Line = lr_Input.readLine()) != null) {
            lv_Input.append(lv_Line);
            break;
        }
        lr_Input.close();
        return lv_Input.toString();
    }
    
}
